<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="ckeditor" uri="http://ckeditor.com" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">   
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <base target="_self"/>
    <title>添加站内消息</title>	
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/commission/css/form.css" />
	<script type="text/javascript" src="../jqGrid/js/jquery-1.7.2.min.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/resources/js/mypage.js"></script>
	<script type="text/javascript" src="../js/jquery.validate.min.js"></script>
	<script type="text/javascript" src="../js/DatePicker/WdatePicker.js" defer="defer"></script>
	<link type="text/css" rel="stylesheet" href="js/ckeditor/contents.css" />
	<script type="text/javascript" src="js/ckeditor/ckeditor.js"></script>
	<script type="text/javascript" src="js/ckfinder/ckfinder.js"></script>
	<script type="text/javascript">
 function show(type){
	if(type==0){
		document.getElementById("showtr").style.display="none";
	}else if(type==1){
		document.getElementById("showtr").style.display="block";
	}
 }
 function selectUser(){
 	  var obj = new Object();
 	  obj.userIds = $("#tmUsersid").val();
 	  var jsons = window.showModalDialog("<%=request.getContextPath()%>/user/chooseAllUser.jsp?temp="+Math.round(Math.random()*10000),obj,"dialogWidth:1010px;dialogHeight:460px;center:yes;resizable:yes;scroll:yes;status:no");
 	  if(typeof(jsons) == "undefined"){
			return false;
	  }
	  if (jsons!=null){
		var usernames = "";
		var userids = "";
		for(var i = 0;i<jsons.length;i++){
			var json = jsons[i];
			usernames += json.username+",";
			userids += json.userid+",";
		}
		if(usernames.length>0){
			usernames = usernames.substring(0,usernames.length-1);
			userids = userids.substring(0,userids.length-1);
		}
		$("#tmUsers").val(usernames);
		$("#tmUsersid").val(userids); 
	  }
 }
 function checkform(){
	if(jQuery.trim($("#tmNoticeTitle").val())==''){
		alert("标题不能为空！");
		return false;
	}
	
	var type = $("#tmNoticeType").val();
	if(type==1){
		if($("#tmUsersid").val()==''){
			alert("必须要选择用户！");
			return false;
		}
	}
	
	var notes = editor.getData();
	if(notes == ''){
		alert("内容不能为空！");
		return false;
	}
}
</script>   
  <style>
  html{   
    overflow-x: hidden; 
	} 
.td_label_zs {
   width: 200px;
   background-color: #FFFFFF;
   height: 20px;
}

.td_value_zs {
    text-align: left;
    background-color: #FFFFFF;
    height: 20px;
}
 
  </style>
    </head>
  
  <body >
  <center>
  <form class="fom" id="fom" method="post" action="sysmessage!addMessage.action" onsubmit="return checkform();" >
           <table style="width:900px;" >
           
                <tr>
                    <td colspan="4" style="background-color:#b7dbf3;text-align:center;height:20px;font-size:18px;font-weight:bold;">消息基本信息</td>
                </tr>
 
                <tr>
				    <td class="td_label_zs" align="left">消息标题：</td>
                    <td class="td_value_zs"  align="left"><input type="text" id="tmNoticeTitle" name="tmNoticeTitle" value="" style="width:400px" /></td>
                    <td class="td_label_zs" align="left">
                            <label for="username">消息类型：</label>
                        </td>
                        <td class="td_value_zs" align="left">
                            <select  name="tmNoticeType" id="tmNoticeType" style="width: 200px;" onchange="show(this.value)">
                                <option value="1" >个人消息</option>                   
                            </select>   
                        </td> 
                </tr>    
                <tr id="showtr">
                      <td class="td_label_zs" align="left">通知人：</td>
                    <td class="td_value_zs" align="left" colspan="3">
                    <input type="hidden" id="tmUsersid" name="tmUsersid" value="" />
                    <input type="text"  style="width:400px" id="tmUsers" name="tmUsers" value="" />
                    <img
							src="<%=request.getContextPath()%>/commission/images/accessories-magnifier.png"
							style="cursor: hand; vertical-align: middle;"
							onclick="selectUser();"></img>
                    </td>
                </tr>  
				<tr>
                    <td class="td_value_zs" colspan="4">
                    <textarea id="tmNotice" name="tmNotice" rows="10" cols="10"></textarea>
                    </td>
                </tr>
				<tr>
                    <td colspan="4" align="center" style="background-color:#b7dbf3;text-align:center;height:20px;font-size:18px;font-weight:bold;">
						<span><input type="submit" value="保 存" class="button_b" /></span>
						<span><input type="button" value="关闭" class="button_b" onclick="window.close();" /></span>
					</td>
                </tr>
            </table>
        </form>
  </center>
  </body>
 <script type="text/javascript">

// This is a check for the CKEditor class. If not defined, the paths must be checked.
if ( typeof CKEDITOR == 'undefined' )
{
	document.write(
		'<strong><span style="color: #ff0000">Error</span>: CKEditor not found</strong>.' +
		'This sample assumes that CKEditor (not included with CKFinder) is installed in' +
		'the "/ckeditor/" path. If you have it installed in a different place, just edit' +
		'this file, changing the wrong paths in the &lt;head&gt; (line 5) and the "BasePath"' +
		'value (line 32).' ) ;
}
else
{
	var editor = CKEDITOR.replace( 'tmNotice' );
	//editor.setData( '<p>Just click the <b>Image</b> or <b>Link</b> button, and then <b>&quot;Browse Server&quot;</b>.</p>' );
	// Just call CKFinder.SetupCKEditor and pass the CKEditor instance as the first argument.
	// The second parameter (optional), is the path for the CKFinder installation (default = "/ckfinder/").
	CKFinder.setupCKEditor( editor, 'js/ckfinder/' ) ;

	// It is also possible to pass an object with selected CKFinder properties as a second argument.
	// CKFinder.SetupCKEditor( editor, { BasePath : '../../', RememberLastFolder : false } ) ;
}

</script>
</html>
